# internal
from coin.support.latency.latency_model import LatencyModel

# std
import sys

if len(sys.argv) != 2:
  print('provide argument e.g. 20190807-20190815')
  sys.exit(1)

model = LatencyModel()
model.train_for_dates(sys.argv[1], 'exchange,market_type')
model.save(path='dump.tmp')

for exchange in [
    'Okex',
    'Upbit',
    'Bithumb',
    'Binance',
    'Huobi',
    'Bitflyer',
    'Korbit',
    'Bitmex',
    'Coinone',
    'Gopax',
    'Kraken'
]:
  for market_type in ['Futures', 'Spot']:
    print(
        f"{exchange:<8} {market_type:<8}: {model.predict({'exchange': exchange, 'market_type': market_type})/1e6:.2f} ms"
    )
